﻿/**
 * @author colin
 */
class com.mixmedia.control.GameTimer extends MovieClip {
	private var startTime:Number;
	private var enabled:Boolean=true;
	private var txt:TextField;
	
	public function Timer(){
		startTime = getTimer();
	}
	
	public function stopTime():Number{
		enabled = false;
		return Math.round(getTimer() - startTime);
	}
	
	public function onEnterFrame(){
		if(enabled){
			var nowTime = Math.round((getTimer() - startTime)/1000);
			var min = Math.floor(nowTime/60);
			var sec = Math.floor(nowTime%60);
			if(min<10){min = "0"+min;}
			if(sec<10){sec = "0"+sec;}
			txt.text = min+":"+sec;
		}
	}
}